using System;

namespace L2NH.Core.Domain
{
   public class Name : IEquatable<Name>
   {
      protected Name()
      {
      }

      public Name(string firstName, string lastName)
      {
         _firstName = firstName;
         _lastName = lastName;
      }

      private readonly string _firstName;
      private readonly string _lastName;

      public virtual string FirstName { get { return _firstName; } }
      public virtual string LastName { get { return _lastName; } }

      public override string ToString()
      {
         return string.Format("{0} {1}", _firstName, _lastName).Trim();
      }

      public virtual bool Equals(Name other)
      {
         if (ReferenceEquals(null, other)) return false;
         if (ReferenceEquals(this, other)) return true;
         return Equals(_firstName, other._firstName) && Equals(_lastName, other._lastName);
      }
      public override bool Equals(object obj)
      {
         return Equals(obj as Name);
      }
      public override int GetHashCode()
      {
         unchecked
         {
            return ((_firstName != null ? _firstName.GetHashCode() : 0) * 397) ^ (_lastName != null ? _lastName.GetHashCode() : 0);
         }
      }
      public static bool operator ==(Name left, Name right)
      {
         return Equals(left, right);
      }
      public static bool operator !=(Name left, Name right)
      {
         return !Equals(left, right);
      }
   }
}